package com.example.seller_svc.controller;

import com.example.seller_svc.model.EntrustOrder;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

@Tag(name = "委托单管理", description = "委托单创建、查询及撤销接口")
@RestController
@RequestMapping("/api/entrusts")
public class EntrustController {

    @Operation(
            summary = "创建委托单",
            description = "创建新的债券委托销售订单",
            responses = {
                    @ApiResponse(responseCode = "200", description = "委托单创建成功"),
                    @ApiResponse(responseCode = "400", description = "参数校验失败")
            }
    )
    @PostMapping
    public ResponseEntity<EntrustOrder> createEntrust(
            @Parameter(description = "委托单参数", required = true)
            @RequestBody EntrustOrder order) {
        // 原有方法实现保持不变
        return ResponseEntity.ok(order);
    }

    @Operation(
            summary = "查询委托单",
            description = "根据ID获取委托单详情",
            responses = {
                    @ApiResponse(responseCode = "200", description = "查询成功"),
                    @ApiResponse(responseCode = "404", description = "委托单不存在")
            }
    )
    @GetMapping("/{id}")
    public ResponseEntity<EntrustOrder> getEntrust(
            @Parameter(description = "委托单ID", example = "123")
            @PathVariable Long id) {
        // 原有方法实现保持不变
        return ResponseEntity.ok(new EntrustOrder());
    }

    @Operation(
            summary = "撤销委托单",
            description = "根据ID撤销未执行的委托单",
            responses = {
                    @ApiResponse(responseCode = "204", description = "撤销成功"),
                    @ApiResponse(responseCode = "403", description = "无权操作")
            }
    )
    @DeleteMapping("/{id}")
    public ResponseEntity<Void> cancelEntrust(
            @Parameter(description = "委托单ID", example = "456")
            @PathVariable Long id) {
        // 原有方法实现保持不变
        return ResponseEntity.noContent().build();
    }
}
